<template>
    <div class="content" ref="count" v-text="count">
    </div>
</template>
<script>
import { debounce } from '@/utils/utils';

export default {
    name: 'Home',
    data() {
        return {
            count: 0
        };
    },
    methods: {
        //移动鼠标计数
        addNum() {
            //获取dom元素
            let dom = this.$refs.count;
            //鼠标移动计数加一
            dom.addEventListener('mousemove', debounce(
                () => {
                    this.count = this.count + 1;
                },
                500,
                false
            ));
        }
    },
    mounted() {
        this.addNum();
    }

};
</script>
<style>
body {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.content {
    height: 200px;
    width: 400px;
    text-align: center;
    line-height: 200px;
    font-size: 80px;
    color: white;
    background: #cccccc;
}
</style>
